package operations;

import javax.swing.JTextArea;

public class ReplaceNextStrategy extends BaseClass  implements ReplaceInterface{
	protected static int StartIndex;
	protected static int EndIndex;
		
	public void ReplacePattern(JTextArea text, String SearchedWord,String ReplacedWord) {
		DefinePattern(text,SearchedWord);
		
		if(SearcheWordSteream.find(EndIndex)){
			text.setText(SearcheWordSteream.replaceFirst(ReplacedWord));
			text.setSelectionStart(SearcheWordSteream.start());
            text.setSelectionEnd(SearcheWordSteream.start()+ReplacedWord.length());
            text.requestFocus();
            EndIndex = SearcheWordSteream.end();
            StartIndex=EndIndex-SearchedWord.length();
		}		
	}
}
